package de.koller.nature.render.obj;

import de.koller.oceanFramework.gl.util.TextureUtil;
import org.lwjgl.opengl.GL11;

public class Tile {
	
	private final int coordX, coordY;
	private final float[][] heightmap;

	public Tile( int coordX, int coordY, float[][] heightmap ) {
		this.coordX = coordX;
		this.coordY = coordY;
		this.heightmap = heightmap;
	}
	
	public void renderThis() {
		GL11.glBegin( GL11.GL_QUADS );
		
			float tx = -1f + (1f / 50f)*coordX;
			float ty = -1f + (1f / 50f)*coordY;
			float td = (1f / 50f);
			GL11.glVertex3f( tx, heightmap[coordX][coordY], ty );
			GL11.glTexCoord2f( 0, 0 );
			GL11.glVertex3f( tx, heightmap[coordX][coordY+1], ty+td );
			GL11.glTexCoord2f( 0, 1 );
			GL11.glVertex3f( tx+td, heightmap[coordX+1][coordY+1], ty+td );
			GL11.glTexCoord2f( 1, 1 );
			GL11.glVertex3f( tx+td, heightmap[coordX+1][coordY], ty );
			GL11.glTexCoord2f( 1, 0 );
		
		GL11.glEnd();
	}
	
}
